package cn.itsource.org.controller;


import cn.itsource.org.domain.Employee;
import cn.itsource.org.domain.Shop;
import cn.itsource.org.query.EmployeeQuery;
import cn.itsource.org.service.IEmployeeService;
import cn.itsource.org.service.IShopService;
import cn.itsource.utils.AjaxResult;
import cn.itsource.utils.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
    springMVC
        @GetMapping  =@RequestMapping( method = {RequestMethod.GET} )
        @PostMapping
        @PatchMapping
        @PutMapping
        @DeleteMapping

 */
@RestController //@Controller +@ResponseBody
@RequestMapping("/shop")
//@CrossOrigin//spring 5及以上的版本能用
public class ShopController {

    @Autowired
    private IShopService shopService;


    //删除的
    @PostMapping("/settlement")
    public AjaxResult settlement(@RequestBody Shop shop){
        System.out.println(shop);
        System.out.println(shop.getAdmin());
        System.out.println(shop.getAdmin().getId());

        try {
            //设置管理员用户默认为待激活的状态
            shop.getAdmin().setState(0);
            shopService.settlement(shop);
            return  AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return  AjaxResult.me().setSuccess(false).setMessage(e.getMessage());
        }
    }


}
